/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.cardamy.core.deck;

import org.cardamy.core.card.Card;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;

/**
 *
 * @author Santiago
 */
public class Deck {
    
    protected ArrayList<Card> _holder = new ArrayList<>();
    
    public Deck addCard(Card card) {
        _holder.add(card);
        return this;
    }
    
    public int size() {
        return _holder.size();
    }
    
    public void shuffle() {
        int size = size();
        int moveTo;
        for(int i = 0; i < size; i++) {
            moveTo = (int) (Math.random() * size);
            Collections.swap(_holder, i, moveTo);
        }
    }
    
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        for (Card card : _holder) {
            sb.append(card).append("\n");
        }
        sb.append("Total Cards").append(this.size());
        return sb.toString();
    }
}
